/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (C) 2012 Regents of the University of California
 */
#include <asm/sbidef.h>
#include <asm/sbiasm.h>
#define CSR_SIE			0x104
#define CSR_SIP			0x144
#define KERNEL_STACK		0x50500000

.section ".entry_function","ax"
.global _start
_start:
  /* Mask all interrupts */
  csrw CSR_SIE, zero
  csrw CSR_SIP, zero

  /* Load the global pointer */
  .option push
  .option norelax
  la gp, __global_pointer$
  .option pop
  /* Clear BSS for flat non-ELF images */
  lui a3,%hi(__bss_start)
  addi a3,a3,%lo(__bss_start)
  lui a4,%hi(__BSS_END__)
  addi a4,a4,%lo(__BSS_END__)
  sb zero,(a3)
  addi a3,a3,1
  blt a4,a3,clear_bss_done
clear_bss:
  sb zero,(a3)
  addi a3,a3,1
  blt a3,a4,clear_bss
clear_bss_done:
  
  /* setup C environment (set sp register)*/
  lui sp,%hi(0x50500000)
  addi  sp,sp,%lo(0x50500000)
  /* Jump to the code in kernel.c*/
  call main
loop:
  wfi
  j loop

